package ext.tianma.bom.service;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 通过物料编号，视图，查询最新版本物料信息
 * 
 * @author Administrator
 * 
 */
@Controller
@RequestMapping({ "/selectPartController" })
public class SelectPartController {

	@RequestMapping(value = "/newestPartMessage", method = {
			RequestMethod.POST, RequestMethod.GET })
	public void newestPartMessage(
			@RequestParam(value = "productNumber", required = true) String productNumber,
			@RequestParam(value = "view", required = false) String view,
			HttpServletResponse response) throws Exception {
		boolean enforce = wt.session.SessionServerHelper.manager
				.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		try {
			String result = SelectPartService
					.getNewestPartMessageByNumberAndView(productNumber, view);
			out.print(result);
		} catch (Throwable e) {
			e.printStackTrace();
		} finally {
			wt.session.SessionServerHelper.manager.setAccessEnforced(enforce);
		}
	}

}
